<?php

/**
* 计算经纬度距离
 */
function GetDistance($lng1,$lat1,$lng2,$lat2){
    //将角度转为狐度
    $radLat1=deg2rad($lat1);//deg2rad()函数将角度转换为弧度
    $radLat2=deg2rad($lat2);
    $radLng1=deg2rad($lng1);
    $radLng2=deg2rad($lng2);
    $a=$radLat1-$radLat2;
    $b=$radLng1-$radLng2;
    $s=2*asin(sqrt(pow(sin($a/2),2)+cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)))*6378.137*1000;//计算出来的结果单位为米
    return floor($s);
}
function curl_get_contents($url,$datas='',$timeout=30) {
    $curlHandle = curl_init();
    curl_setopt( $curlHandle , CURLOPT_URL, $url );
    curl_setopt( $curlHandle , CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt( $curlHandle , CURLOPT_TIMEOUT, $timeout );
    curl_setopt($curlHandle, CURLOPT_HEADER, false);
    if(!$data = ''){
        curl_setopt($curlHandle, CURLOPT_POST,1);
        curl_setopt($curlHandle, CURLOPT_POSTFIELDS,$datas);
    }
    //echo $url;
    $result =curl_exec($curlHandle );
  //  file_put_contents("curl_error.txt",curl_error($curlHandle));
    curl_close( $curlHandle );

    return $result;
}


?>